//
//  MeetingCell.m
//  iHeima
//
//  Created by he chao on 5/28/14.
//  Copyright (c) 2014 leon. All rights reserved.
//

#import "MeetingCell.h"
#import "MeetingBoard.h"

@implementation MeetingCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)initSelf{
    avatar = [AvatarView initFrame:CGRectMake(7, 7, 60, 60) image:nil borderColor:[UIColor clearColor]];
    avatar.backgroundColor = [UIColor grayColor];
    [self addSubview:avatar];
    
    title = [BaseLabel initLabel:@"提提神两地分居了卡死" font:FONT(14) color:kNormalColor textAlignment:NSTextAlignmentLeft];
    title.frame = CGRectMake(avatar.right+10, 0, 200, 38);
    [self addSubview:title];
    
    count = [BaseLabel initLabel:@"/6" font:FONT(14) color:kNormalColor textAlignment:NSTextAlignmentRight];
    count.frame = CGRectMake(0, title.top, 310, title.height);
    [self addSubview:count];
    
    inPerson = [BaseLabel initLabel:@"4" font:FONT(14) color:kBlueColor textAlignment:NSTextAlignmentRight];
    inPerson.frame = CGRectMake(0, title.top, 297, title.height);
    [self addSubview:inPerson];
    
    iconStatus = [BeeUIImageView spawn];
    iconStatus.frame = CGRectMake(title.left, 40, 26, 26);
    [self addSubview:iconStatus];
    
    btnIn = [BaseButton initBaseBtn:nil highlight:nil];
    btnIn.frame = CGRectMake(150, 38, 95, 29);
    [self addSubview:btnIn];
}

- (void)load{
    title.text = self.dictMeeting[@"title"];
    inPerson.text = self.dictMeeting[@"num"];
    
    iconStatus.image = [self.dictMeeting[@"anonymous"] boolValue]?IMAGESTRING(@"meeting_disable"):IMAGESTRING(@"meeting_enable");
    
    [avatar setImageWithURL:[NSString stringWithFormat:@"%@avatar.php?uid=%@&size=middle",kPicUrl,self.dictMeeting[@"uid"]] placeholderImage:IMAGESTRING(@"default_avatar")];
    
    btnIn.userInteractionEnabled = NO;
    switch ([self.dictMeeting[@"showtype"] intValue]) {
        case 1:
        {
            [btnIn setImage:IMAGESTRING(@"meeting_btn_accept") forState:UIControlStateNormal];
        }
            break;
        case 2:
        {
            [btnIn setImage:IMAGESTRING(@"meeting_btn_enable") forState:UIControlStateNormal];
        }
            break;
        case 3:
        {
            [btnIn setImage:IMAGESTRING(@"meeting_btn_disable") forState:UIControlStateNormal];
        }
            break;
            
        default:
            break;
    }
//    if ([self.dictMeeting[@"opentype"] intValue]==1) {
//        btnIn.userInteractionEnabled = NO;
//        [btnIn addSignal:MeetingBoard.ADD_IN forControlEvents:UIControlEventTouchUpInside object:nil];
//        [btnIn setImage:IMAGESTRING(@"meeting_btn_enable") forState:UIControlStateNormal];
//    }
//    else {
//        btnIn.userInteractionEnabled = NO;
//        [btnIn setImage:IMAGESTRING(@"meeting_btn_disable") forState:UIControlStateNormal];
//    }
}

@end
